Skip to content

Conversation

@pcrespov
Copy link
Member

@pcrespov pcrespov commented Jun 11, 2025

What do these changes do?

In master deploy we still notice LineTooLong error but the issue cannot be really traced in our code base.

image

In this PR we implement a long expected refactoring of the errors middleware. The new design:

  • implements separates handlers for all type of web.HTTPException as well as other exceptions into http errors
  • handles when the handle implementations raise themselves exceptions (e.g. LineTooLong error that motivated this PR)

Related issue/s

How to test

cd packages/service-library
make "install-dev[aiohttp]|
pytest -vv tests/aiohttp/test_rest_middlewares.py

Dev-ops

None

@codecov
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 87.87879% with 8 lines in your changes missing coverage. Please review.

Project coverage is 87.46%. Comparing base (a5e90f2) to head (d17cb02).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7878      +/-   ##
==========================================
- Coverage   87.98%   87.46%   -0.52%     
==========================================
  Files        1844     1394     -450     
  Lines       71034    57208   -13826     
  Branches     1219      619     -600     
==========================================
- Hits        62499    50039   -12460     
+ Misses       8187     6960    -1227     
+ Partials      348      209     -139     
Flag Coverage Δ *Carryforward flag
integrationtests 64.00% <ø> (-0.32%) ⬇️ Carriedforward from 5d7d7ce
unittests 85.84% <87.87%> (-0.73%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 72.63% <87.87%> (+0.23%) ⬆️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.10% <ø> (+0.05%) ⬆️
agent 96.29% <ø> (ø)
api_server 91.76% <ø> (ø)
autoscaling ∅ <ø> (∅)
catalog 92.29% <ø> (ø)
clusters_keeper 99.13% <ø> (ø)
dask_sidecar 91.79% <ø> (+0.22%) ⬆️
datcore_adapter 97.94% <ø> (ø)
director 76.73% <ø> (ø)
director_v2 90.49% <ø> (-0.62%) ⬇️
dynamic_scheduler 96.69% <ø> (ø)
dynamic_sidecar 89.18% <ø> (-0.92%) ⬇️
efs_guardian 89.65% <ø> (ø)
invitations 93.00% <ø> (ø)
payments 92.57% <ø> (ø)
resource_usage_tracker 89.09% <ø> (+0.10%) ⬆️
storage 87.60% <ø> (-0.18%) ⬇️
webclient ∅ <ø> (∅)
webserver 87.63% <ø> (-0.07%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5e90f2...d17cb02. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pcrespov pcrespov self-assigned this Jun 11, 2025
@pcrespov pcrespov added a:webserver webserver's codebase. Assigning the area is particularly useful for bugs a:services-library issues on packages/service-libs labels Jun 11, 2025
@pcrespov pcrespov added this to the Engage milestone Jun 11, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the error middleware to address the LineTooLong error and improves the error handling pipeline for HTTP exceptions. Key changes include:

  • Refactored error middleware logic with dedicated handlers for various HTTP exceptions.
  • Enhanced HTTP error formation with proper envelope wrapping and logging.
  • Added tests to verify the handling of NotImplementedError, TimeoutError, and unexpected exceptions.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/service-library/tests/aiohttp/test_rest_middlewares.py Introduced new tests to verify correct error mapping and envelope wrapping.
packages/service-library/src/servicelib/aiohttp/rest_responses.py Updated HTTP error creation logic with refined message handling.
packages/service-library/src/servicelib/aiohttp/rest_middlewares.py Refactored error handling functions and middleware to improve robustness and clarity.
Comments suppressed due to low confidence (1)

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py:129

  • The function uses 'json_loads' without an explicit import. Consider importing it or using the appropriate function from the common library to ensure consistency.
payload = json_loads(exception.text)

@pcrespov pcrespov changed the title Mai/fix line too long error ♻️🐛Refactors webserver's errors middleware to handle LineTooLong exceptions Jun 11, 2025
@pcrespov pcrespov enabled auto-merge (squash) June 11, 2025 18:41
@pcrespov
Copy link
Member Author

@mergify queue

@pcrespov pcrespov added the 🤖-automerge marks PR as ready to be merged for Mergify label Jun 11, 2025
@mergify
Copy link
Contributor

mergify bot commented Jun 11, 2025

queue

🛑 The pull request has been removed from the queue default

The following conditions don't match anymore:

  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • any of: [🛡 GitHub branch protection]
        • check-neutral = deploy to dockerhub
        • check-skipped = deploy to dockerhub
        • check-success = deploy to dockerhub
      • any of: [🛡 GitHub branch protection]
        • check-neutral = system-tests
        • check-skipped = system-tests
        • check-success = system-tests
      • any of: [🛡 GitHub branch protection]
        • check-neutral = unit-tests
        • check-skipped = unit-tests
        • check-success = unit-tests
      • any of: [🛡 GitHub branch protection]
        • check-neutral = integration-tests
        • check-skipped = integration-tests
        • check-success = integration-tests

@pcrespov pcrespov requested review from odeimaiz and wvangeit June 11, 2025 18:49
Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pcrespov pcrespov force-pushed the mai/fix-line-too-long-error branch from a9a62dd to 30ea3fe Compare June 12, 2025 09:08
@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@sonarqubecloud
Copy link

@pcrespov pcrespov merged commit 9705882 into ITISFoundation:master Jun 13, 2025
93 of 95 checks passed
@pcrespov pcrespov deleted the mai/fix-line-too-long-error branch June 13, 2025 09:55
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 5, 2025
88 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:services-library issues on packages/service-libs a:webserver webserver's codebase. Assigning the area is particularly useful for bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants